package com.mes.spc.rule;

public class SpcRule2 extends SPCCommandbase {

    public int id = 2;
    public int warningCount = 9;
    public String title = "规则2";
    public String description= "连续9点落在中心线同一侧";

    private int count = 0;
    private Boolean up = true;
    public boolean excute(double data, double usl, double lsl, double ucl, double lcl, double standard)
    {
        if(data==standard)
        {
            up = null;
            count = 0;
            return false;
        }
        boolean temp = data > standard;
        if (count > 0 && temp == up)
        {
            count++;
            if (count >= 9)
                return true;
        }
        else
        {
            up = temp;
            count = 1;
        }
        return false;
    }

    public int getId() {
        return id;
    }

    public int getWarningCount() {
        return warningCount;
    }

    public String getTitle() {
        return title;
    }

    public String getDescription() {
        return description;
    }
}
